package algorithm.poj.p1000;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLDecoder;
import java.util.StringTokenizer;

/**
 * 分析：
 * 实现：
 * 经验：
 * 教训：
 * 
 * 
 * @author wong.tong@gmail.com
 *
 */
public class P1102 {

	public static void main(String[] args) throws Exception {

		InputStream input = null;
		if (false) {
			input = System.in;
		} else {
			URL url = P1102.class.getResource("P1102.txt");
			File file = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
			input = new FileInputStream(file);
		}
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(input));

		while (true) {
			StringTokenizer st = new StringTokenizer(stdin.readLine());
			int s = Integer.valueOf(st.nextToken());
			if (s == 0) return;
			char[] cs = st.nextToken().toCharArray();
			int[] ns = new int[cs.length];
			for (int i = 0; i < ns.length; i ++) ns[i] = cs[i] - '0';
			
			lcd(ns, s);
		}
	}

	private static int[][] bits = {
			new int[] {1,1,1,0,1,1,1},	//0
			new int[] {0,0,1,0,0,1,0},	//1
			new int[] {1,0,1,1,1,0,1},	//2
			new int[] {1,0,1,1,0,1,1},	//3
			new int[] {0,1,1,1,0,1,0},	//4
			new int[] {1,1,0,1,0,1,1},	//5
			new int[] {1,1,0,1,1,1,1},	//6
			new int[] {1,0,1,0,0,1,0},	//7
			new int[] {1,1,1,1,1,1,1},	//8
			new int[] {1,1,1,1,0,1,1}	//9
	};
	
	private static void lcd(int[] ns, int s) {
		
		StringBuffer output = new StringBuffer("");
		output.append(getXString(ns, s, 0));
		output.append(getYString(ns, s, 1, 2));
		output.append(getXString(ns, s, 3));
		output.append(getYString(ns, s, 4, 5));
		output.append(getXString(ns, s, 6));
		System.out.println(output);
	}

	private static StringBuffer getYString(int[] ns, int s, int left, int right) {
		
		StringBuffer output = new StringBuffer("");
		for (int k = 0; k < s; k ++) {
			for (int i = 0; i < ns.length; i ++) {
				if (bits[ns[i]][left] == 1) {
					output.append("|");
					for (int j = 0; j < s; j ++) output.append(" ");
				} else {
					for (int j = 0; j < s+1; j ++) output.append(" ");
				}
				if (bits[ns[i]][right] == 1) {
					output.append("|");
				} else {
					output.append(" ");
				}
				if (i != ns.length-1) output.append(" ");
			}
			output.append("\n");
		}
		return output;
	}

	private static StringBuffer getXString(int[] ns, int s, int index) {
		
		StringBuffer output = new StringBuffer("");
		for (int i = 0; i < ns.length; i ++) {
			if (bits[ns[i]][index] == 1) {
				output.append(" ");
				for (int j = 0; j < s; j ++) output.append("-");
				output.append(" ");
			} else {
				for (int j = 0; j < s+2; j ++) output.append(" ");
			}
			if (i != ns.length-1) output.append(" ");
		}
		output.append("\n");
		return output;
	}

}